﻿using ChoWorkflowServer.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace ChoWorkflowServer.ModelWCF.Host
{
    public class ChoTaskSchedule
    {
        public int ScheduleId { get; set; }
        public string ScheduleName { get; set; }
        public string ScheduleDesc { get; set; }

        public int TaskId { get; set; }
        public bool Enabled { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime? EndDate { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime? EndTime { get; set; }
        public int? HolidayCalId { get; set; }
        public int? ScheduleTypeId { get; set; }
        public int? T1 { get; set; }
        public int? DailyEveryDays { get; set; }
        public int? WeeklyEveryWeeks { get; set; }
        public bool Sun { get; set; }
        public bool Mon { get; set; }
        public bool Tue { get; set; }
        public bool Wed { get; set; }
        public bool Thu { get; set; }
        public bool Fri { get; set; }
        public bool Sat { get; set; }
        public bool? MonthlyDayOfMonth { get; set; }
        public int? MonthlyEveryDayOfMonth { get; set; }
        public int? MonthlyEveryWeekOfMonth { get; set; }
        public int? MonthlyEveryWeekDayOfMonth { get; set; }
        public string MonthlySelectedMonth { get; set; }
        public bool RepeatEnabled { get; set; }
        public int? RepeatInterval { get; set; }
        public int? RepeatIntervalType { get; set; }
        public string Dependencies { get; set; }
        public int FireAfterDependency { get; set; }
        public string CreatedBy { get; set; }
        public DateTime CreatedDate { get; set; }
        public string ModifiedBy { get; set; }
        public DateTime ModifiedDate { get; set; }
    }

    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        Version GetVersion();
        [OperationContract]
        int GetTaskId(string taskName);
        //[OperationContract]
        //bool IsTaskExists(string taskName, out bool isDeleted);
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "AddOrUpdateTask", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        int AddOrUpdateTask(string taskName, string workflowName, string taskDesc, int taskGroupId, string cmdParameters,
            int? maxNoOfRetry, int? sleepBetweenRetry, int? timeout, string hostName,
            ChoTaskSchedule[] taskScheduleInfo, string modifiedBy, string modifiedByHostName);
        //[OperationContract]
        //int CloneTask(string taskName, string newTaskName, string taskGroupName, string modifiedBy, string machineName);
        //[OperationContract]
        //void DeleteTask(string taskName, string modifiedBy, string machineName);
        //[OperationContract]
        //ChoTasksDataSet.CHO_TASKSDataTable GetAllUITasks(string taskName, string taskGrpName);
        //[OperationContract]
        //ChoTasksDataSet.CHO_TASKSDataTable GetAllTasks(string taskName, string taskGrpName, string machineName, DateTime modifiedDate);
        //[OperationContract]
        //void UndeleteTask(string taskName, string modifiedBy, string machineName);

        //[OperationContract]
        //void SetTaskStatus(int batchId, string taskName, string scheduleName, Cinchoo.Core.ETL.ChoETLWorkflowStatus taskStatus, string modifiedBy, string modifiedByHostName, string logMsg = null, DateTime? nextRunTime = null);
        //[OperationContract]
        //Cinchoo.Core.ETL.ChoETLWorkflowStatus GetTaskStatus(string taskName, string scheduleName);
        //[OperationContract]
        //int GetTaskExitCode(string taskName, string scheduleName);
        //[OperationContract]
        //void AddOrUpdateTaskBatch(int batchId, string taskName, string scheduleName, int taskStatus, string cmdParameters, string logMsg, DateTime processStart,
        //    DateTime? processEnd, TimeSpan? duration, DateTime? nextRunTime, int exitCode, int? retryCount, string modifiedBy, string machineName);

        //[OperationContract]
        //int AddOrUpdateTaskGroup(string taskGroupName, string taskGroupDesc, int parent, string modifiedBy, string machineName);
        //[OperationContract]
        //void DeleteTaskGroup(string taskGroupName, string modifiedBy, string machineName);
        //[OperationContract]
        //bool IsTaskGroupExists(string taskGroupName, out bool isDeleted);
        //[OperationContract]
        //void UndeleteTaskGroup(string taskGroupName, string modifiedBy, string machineName);
        //[OperationContract]
        //void MoveTask(string taskName, int srcTaskGrpId, int destTaskGrpId, string modifiedBy, string machineName);

        //[OperationContract]
        //ChoTasksDataSet.CHO_HOLIDAY_CALENDARSDataTable GetAllHolidayCalendars();
        //[OperationContract]
        //void UpdateHolidayCalendar(ChoTasksDataSet.CHO_HOLIDAY_CALENDARSDataTable calendarTable,
        //    ChoTasksDataSet.CHO_HOLIDAY_CALENDAR_DATESDataTable calendarDatesTable, string modifiedBy, string machineName);
        //[OperationContract]
        //ChoTasksDataSet.CHO_HOLIDAY_CALENDAR_DATESDataTable GetAllHolidayCalendarDatesById(int holidayCalId);
        //[OperationContract]
        //ChoTasksDataSet.CHO_HOLIDAY_CALENDAR_DATESDataTable GetAllHolidayCalendarDatesByName(string holidayCalName);
        //[OperationContract]
        //int CloneCalendar(string calName, string newCalName, string modifiedBy, string machineName);

        //[OperationContract]
        //ChoTasksDataSet.CHO_TASK_SCHEDULESDataTable GetTaskSchedules(int taskId, string scheduleName);
        //[OperationContract]
        //ChoTasksDataSet.CHO_SCHEDULE_TYPESDataTable GetTaskScheduleTypes();

        //[OperationContract]
        //ChoTasksDataSet.CHO_POLICYDataTable GetAllPolicy();
        //[OperationContract]
        //ChoTasksDataSet.CHO_USERSDataTable GetAllUsers();
        //[OperationContract]
        //void UpdateUsers(ChoTasksDataSet.CHO_USERSDataTable usersTable, string modifiedBy, string machineName);

        //[OperationContract]
        //ChoTasksDataSet.CHO_ROLESDataTable GetAllRoles();
        //[OperationContract]
        //ChoTasksDataSet.CHO_ROLE_USERSDataTable GetAllUserRoles(int roleId);
        //[OperationContract]
        //ChoTasksDataSet.CHO_ROLE_POLICYDataTable GetAllRolePolicy(int roleId);
        //[OperationContract]
        //void UpdateRoles(ChoTasksDataSet.CHO_ROLESDataTable rolesTable, ChoTasksDataSet.CHO_ROLE_USERSDataTable userRolesTable,
        //    ChoTasksDataSet.CHO_ROLE_POLICYDataTable rolesPolicyTable, string modifiedBy, string machineName);
        //[OperationContract]
        //ChoTasksDataSet.CHO_POLICYDataTable GetPolicyForUser(string userName);

        //[OperationContract]
        //ChoTasksDataSet.CHO_DEPENDENCY_TASKSDataTable GetAllDepedencyTasks(string jobName);
    }

    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    // You can add XSD files into the project. After building the project, you can directly use the data types defined there, with the namespace "ChoWorkflowServer.ModelWCF.Host.ContractType".
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }
}
